package com.controller;

import com.dao.userMapper;
import com.model.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;


@Controller
public class LoginController {

    @Resource
    private userMapper userMapper;

    @RequestMapping("/")
    public String home() {
        return "login";
    }

    @RequestMapping("/login.html")
    public String login() {
        return "login";
    }


    @RequestMapping("/login.json")
    @ResponseBody
    public ResponseData login( String account ,String password) {

        User user = new User(account,password);
        user = userMapper.selectOne( user );
        if (user != null){
            return new ResponseData(true,"登录成功<br /><br />欢迎进入");
        }else{
            return new ResponseData(false,"登录失败<br /><br />账号或密码不正确");
        }
    }


}
